/* vim: set ts=2 et sw=2 cindent fo=qroca: */

package com.globant.google.mendoza.command;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import com.globant.google.mendoza.MendozaServer;
import com.globant.google.mendoza.MendozaRequest;
import com.globant.google.mendoza.MendozaServerState;

/** Represents the reset mendoza server command.
 */
public final class MendozaResetCommand extends MendozaBaseCommand {

  /** The class logger.
   */
  private static Log log = LogFactory.getLog(MendozaResetCommand.class);

  /** Creates an instance of MendozaResetCommand.
   *
   * @param mendozaRequest The mendoza server request.
   *
   * @param mendoza The mendoza server.
   *
   * @param mendozaState The mendoza server state.
   */
  public MendozaResetCommand(
      final MendozaRequest mendozaRequest, final MendozaServer mendoza,
      final MendozaServerState mendozaState) {
    super(mendozaRequest, mendoza, mendozaState);
    setName("Reset");
  }

  /** Executes the mendoza server reset command.
   */
  public void execute() {
    log.trace("Entering execute");
    String commandResultMsg =
      "OK - Reset command sent to the mendoza server.";
    getMendozaState().reset();
    getMendoza().getMendozaStatus().reset();
    MendozaCommandResult result = new MendozaCommandResult();
    result.setSuccess(commandResultMsg);
    setResult(result);
    log.trace("Leaving execute");
  }
}

